<!DOCTYPE HTML>
<html lang="zh">
<meta charset="utf-8">
<head>
	<link href="/aityWeb/static/css/font-awesome.css" rel="stylesheet"/>

	<style type="text/css">
		.nav > li:hover .dropdown-menu {display: block;}
	</style>

	<link href="/aityWeb/static/css/bootstrap.min.css" rel="stylesheet"/>
	<link href="/aityWeb/static/css/font-awesome.css" rel="stylesheet"/>
	<!-- bootstrap-table 表格插件样式 -->
	<link href="/aityWeb/static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>
	<link href="/aityWeb/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.css" rel="stylesheet"/>
	<link href="/aityWeb/static/css/animate.css" rel="stylesheet"/>
	<link href="/aityWeb/static/css/style.css" rel="stylesheet"/>
	<link href="/aityWeb/static/css/checkbox.css" rel="stylesheet"/>
	<link href="/aityWeb/static/ajax/libs/select/select2.css" rel="stylesheet"/>
	<link href="/aityWeb/static/galaxy/css/ry-ui.css" rel="stylesheet"/>
	<link rel="stylesheet" href="/aityWeb/static/css/cropper.css">
	<link rel="stylesheet" href="/aityWeb/static/css/corperpic.css">
	<style type="text/css">
		.col-sm-3 {
		    padding: 5px;
		    margin-top: 5px;
		}
		.col-md-6 {
		    padding: 5px;
		}
		
	</style>

</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 select-info" style="padding-top: 10px;">
			<ul class="breadcrumb" style="font-size: 16px;background-color: #f3f3f3;padding: 5px 10px;color: #337ab7;">
				<li><i class="fa fa-home" aria-hidden="true"></i>&nbsp;&nbsp;<a href="#">首页</a></li>
				<li class="active"><a href="#">车辆管理</a></li>
				<li class="active"><a href="#">车辆登记</a></li>
			</ul>
			<div class="col-sm-12 " style="padding-top: 10px;height: 100%">
				<div class="row">

						<!-- 新加入信息开始 -->
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">车辆所在省份*</label>
								<div class="col-sm-9">
									<select id="prov" name="proName" class="form-control" data-valid="required" data-tips="请选择场馆所在省份">
									</select>
								</div>

							</div>
						</div>
						<!-- 新加入信息结束 -->

						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">车辆所在城市*</label>
								<div class="col-sm-9">
									<select id="city" name="cityName" class="form-control" data-valid="required" data-tips="请选择场馆所在城市">
									</select>
								</div>
							</div>
						</div>

					</div>
					<h3>基础信息</h3>
					<!-- <div class="row" style="display: none;">
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">场馆ID</label>
								<div class="col-sm-9">
									<input id="shopid" name="id" class="form-control" type="text" placeholder="场馆ID" data-valid="required" data-tips="自动生成" disabled>
								</div>
							</div>
						</div>
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">场馆图标</label>
								<div class="col-sm-7">
									<input name="attachmentId" class="form-control" type="text" placeholder="场馆图标ID" data-valid="required" data-tips="图标" disabled>
								</div>
								<div class="col-sm-2">
									<button type="button" id="check_code_btn" class="btn btn-primary">检查</button>
								</div>
							</div>
						</div>
					</div> -->
					<div class="row">
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">车主名称*</label>
								<div class="col-sm-9">
									<input name="driver" class="form-control" type="text" placeholder="车主名称" data-valid="required" data-tips="请填写车主名称">
								</div>
							</div>
						</div>
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">车牌号码*</label>
								<div class="col-sm-7">
									<input name="code" class="form-control" type="text" placeholder="车牌号码" data-valid="required" data-tips="请填写车牌号码">
								</div>			
							</div>
						</div>
					</div>   
					<div class="row">
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">车辆型号*</label>
								<div class="col-sm-9">
									<input name="carType" class="form-control" type="text" placeholder="车辆型号" data-valid="required" data-tips="请填写车辆型号">
								</div>
							</div>
						</div>
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">手机号码*</label>
								<div class="col-sm-7">
									<input name="phoneNum" class="form-control" type="text" placeholder="手机号码" data-valid="required" data-tips="请填写手机号码">
								</div>			
							</div>
						</div>
					</div>         
					<div class="row">
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">登记日期*</label>
								<div class="col-sm-9">
									<input name="registDate" class="form-control" type="date" placeholder="登记日期" data-valid="required" data-tips="请填写登记日期">
								</div>
							</div>
						</div>
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">生产日期*</label>
								<div class="col-sm-7">
									<input name="productDate" class="form-control" type="date" placeholder="生产日期" data-valid="required" data-tips="请填写生产日期">
								</div>			
							</div>
						</div>
					</div>
					

					<div class="row">
						
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">年检状态</label>
								<div class="col-sm-7 readonly">
									<label class="radio-inline">
										<input name="rate" type="radio" value="1">已检
									</label>
									<label class="radio-inline">
										<input name="rate" type="radio" value="2" >未检
									</label>
								</div>
							</div>
						</div>
					</div>

					

					<div class="row">
						<div class="col-md-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">来访事由</label>
								<div class="col-sm-9">
									<textarea name="detail" class="form-control" rows="6"></textarea>
								</div>
							</div>
						</div>
					</div>


					<h3>图片信息</h3>
					
					<div class="row">
						<div class="col-md-12">
							<div class="form-group">
								<label class="col-sm-3 control-label">车辆图片</label>
								<div class="col-sm-3">
									<button class="btn btn-primary " id="select_photo" type="button">选择图片</button>
								</div>
								<div id="shop_pics">
									

								</div>
							</div>
						</div>
					</div>
					
					
					<hr>
					<div class="row">
						<div class="col-md-12" style="text-align:center">
							<button id="submitinfo" class="btn btn-danger btn-lg submit-btn" type="button">提交</button>
							<button class="btn btn-default btn-lg " id="add_edit_close_btn" type="button">返回</button>
						</div>
					</div>
	

			</div>
			<div class="modal fade" id="shop_modal">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							<h4 class="modal-title">场馆拒绝审核</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" id="add_item_form">
								<div class="row">
									<div class="form-group">
										<label class="col-sm-3 control-label">审核原因</label>
										<div class="col-sm-9">
											<textarea id="examineContent" name="content" class="form-control" type="text" placeholder="资讯内容" data-valid="required" data-tips="请填写资讯内容"></textarea>
										</div>
									</div>
								</div>
							</form>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" id="item_close">关闭</button>
							<button type="button" class="btn btn-primary submit_item_btn" data-method="one" id="item_submit_save">保存</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
		</div>
		<div class="modal fade" id="map_modal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" id="j_btnAddData" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title">地图</h4>
					</div>
					<div class="modal-body">
						<div id="allmap" style="width:100%; height:400px;"></div>
					</div>
					<div class="modal-footer">
						<button type="button" id="#j_formAdd" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		<!-- /.modal -->
		
		<div class="modal fade" id="iconchangeModal"  tabindex="1" role="dialog" data-type="photo">
			<div class="modal-dialog">
				<div class="modal-content">
				    <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				        <h4 class="modal-title text-primary">
				        <i class="fa fa-pencil"></i>
							图片上传
				        </h4>
				    </div>
				    <div class="modal-body">
				        <p class="tip-info text-center">
							未选择图片
				        </p>
				        <div class="img-container hidden">
				            <img src="" alt="" id="icon">
				        </div>
				        <div class="img-preview-box hidden">
				            <hr>
				            <span>选择:</span>
				            <div class="img-preview img-preview-lg">
				            </div>
				        </div>
				    </div>
				    <div class="modal-footer">
				        <label class="btn btn-danger pull-left" for="iconInput">
					        <input type="file" class="sr-only" id="iconInput" accept="image/png,image/jpeg">
					        <span>打开图片</span>
				        </label>
				        <button class="btn btn-primary disabled" disabled="true" onclick="sendIconEx();">提交</button>
				        <button class="btn btn-close" data-dismiss="modal">取消</button>
				    </div>
				</div>
			</div>
		</div>

		<div class="modal fade" id="changeModal"  tabindex="1" role="dialog" data-type="photo">
			<div class="modal-dialog">
				<div class="modal-content">
				    <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				        <h4 class="modal-title text-primary">
				        <i class="fa fa-pencil"></i>
							图片上传
				        </h4>
				    </div>
				    <div class="modal-body">
				        <p class="tip-info text-center">
							未选择图片
				        </p>
				        <div class="img-container hidden">
				            <img src="" alt="" id="photo">
				        </div>
				        <div class="img-preview-box hidden">
				            <hr>
				            <span>选择:</span>
				            <div class="img-preview img-preview-lg">
				            </div>
				        </div>
				    </div>
				    <div class="modal-footer">
				        <label class="btn btn-danger pull-left" for="photoInput">
					        <input type="file" class="sr-only" id="photoInput" accept="image/png,image/jpeg">
					        <span>打开图片</span>
				        </label>
				        <button class="btn btn-primary disabled" disabled="true" onclick="sendPhotoEx();">提交</button>
				        <button class="btn btn-close" data-dismiss="modal">取消</button>
				    </div>
				</div>
			</div>
		</div>
			</div>
	</div>


<script src="/aityWeb/static/js/jquery.min.js"></script>
<script src="/aityWeb/static/js/bootstrap.min.js"></script>
<script src="/aityWeb/static/js/echarts.common.min.js"></script>
<script type="text/javascript" src="/aityWeb/static/js/app/corporpic.js"></script>
<script type="text/javascript" src="/aityWeb/static/js/lib/cropper.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yhwiYpZCUT0bEzYvgF39WDGLDxowWbpQ"></script>
<!-- bootstrap-table 表格插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
<!-- jquery-validate 表单验证插件 -->
<script src="/aityWeb/static/ajax/libs/validate/jquery.validate.min.js"></script>
<script src="/aityWeb/static/ajax/libs/validate/messages_zh.min.js"></script>
<script src="/aityWeb/static/ajax/libs/validate/jquery.validate.extend.js"></script>
<!-- jquery-validate 表单树插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
<!-- jquery-export 表格导出插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
<!-- 遮罩层 -->
<script src="/aityWeb/static/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="/aityWeb/static/ajax/libs/layer/layer.min.js"></script>
<script src="/aityWeb/static/ajax/libs/layui/layui.js"></script>
<script src="/aityWeb/static/galaxy/js/common.js?v=2.3.0"></script>
<script src="/aityWeb/static/galaxy/js/ry-ui.js?v=2.3.0"></script>

<script src="/aityWeb/static/js/app/net.js"></script>
<script src="/aityWeb/static/js/app/app.js"></script>
<script src="/aityWeb/static/js/lib/MD5.js"></script>

<script src="/aityWeb/static/js/app/corporpic.js"></script>
<script type="text/javascript">
$(function() {
	//查询本地数据
	var sets = getSettings();
	
	//获取页面参数
	var re = GetRequest();

	//图片裁剪初始化
	initCropperInModal($('#photo'),$('#photoInput'),$('#changeModal'),2);
	initCropperInModal($('#icon'),$('#iconInput'),$('#iconchangeModal'),1);

if(re.isReviewRight==true){
			$('#reviewOK').css('display','none');
			$('#refuse').css('display','none');
}
	//编辑场景，读取场馆信息
	if(re['action'] == 'edit' || re['action'] == 'review' || sets.isShopUser){

		//读取省列表
		var info = {
			page: 1,
			rows: 100,
			type:"select"
		};
		
		//接口调用
		var str = '';
		doPost("base/getGroupsList",info,function(data){
			//加载数据列表
			if(data.success){
				var data = data.data;
				var r = data.rows;
				for(var i = 0; i < r.length; i++) {
					syslog(r[i]);
					str += '<option value=' + r[i].id + '>' + r[i].name + '</option>';
				}
				$('#prov').html(str);

				//读取场馆信息
				var pages = 1;
				var rows = 10;
				var info = {
					page: pages,
					rows: rows,
					id:parseInt(re['shopid'])
				};
				var addr = {
					city:"",
					cityid:0,
					provid:0,
					area:"",
					areaid:0
				};
				doPost("shop/selectByShop",info,function(data){
					
					if(data.success){
						var data = data.data;
						var r = data.rows;
						var str = '';
						$('[name="id"]').val(r[0].id);
						$('[name="attachmentId"]').val(r[0].attachmentId);
						$('[name="name"]').val(r[0].name);
						$('[name="code"]').val(r[0].code);
						$('[name="project"]').val(r[0].project);
						$('input[name="status"][value=' + r[0].status + ']').attr("checked",true);
						$('input[name="isSign"][value=' + r[0].issign + ']').attr("checked",true);
						$('input[name="rate"][value=' + r[0].rate + ']').attr("checked",true);
						$('input[name="isView"][value=' + r[0].isview + ']').attr("checked",true);
						$('input[name="isRecommend"][value=' + r[0].isrecommend + ']').attr("checked",true);
						$('[name="detail"]').val(r[0].detail);
						$('[name="sort"]').val(r[0].sort);
		//				$('[name="recKeyword"]').val(r[0].name);
						$('[name="phone"]').val(r[0].phone);
						$('[name="lat"]').val(r[0].lng);
						$('[name="lng"]').val(r[0].lat);
						$('[name="address"]').val(r[0].address);
						//$('[name="manager"]').val(r[0].username);
						$('[name="manager"]').val('mgr_' + r[0].code + ',cw' +  + r[0].code);
						addr.city = r[0].cityname;
						addr.cityid = parseInt(r[0].city);
						addr.provid = parseInt(r[0].groupid);
						addr.area = r[0].areatext;
						addr.areaid = parseInt(r[0].area);
						
						document.getElementById('prov').value = addr.provid;
						
						//加载图片
						if(r[0].imgAttachment > 0){
							var img = $('#shop-icon'); 
            				img.attr('src', imgurl + r[0].attachmentPath);
            				img.attr('data-id',r[0].imgAttachment);
						}
						if(r[0].shopManageImgs.length > 0){
							var imglist = document.getElementById('shop_pics');
							imglist.innerHTML = "";
            
				            for(var i = 0;i < r[0].shopManageImgs.length;i++){
					            //var str = '<div class="shop_img_list_card" data-id="' + r[0].shopManageImgs[i].imgAttachment +'"><img src="' + imgurl + r[0].shopManageImgs[i].attachmentPath +'" class="shop_img_list" data-id="' + r[0].shopManageImgs[i].imgAttachment +'"  data-toggle="popover" title="点击即可删除"/></div>';
					            var str = '<img src="' + imgurl + r[0].shopManageImgs[i].attachmentPath +'" class="shop_img_list" data-id="' + r[0].shopManageImgs[i].imgAttachment +'"  data-toggle="popover" title="点击即可删除"/>';
					            imglist.innerHTML += str;
				            }
				            $(".shop_img_list").click(function(){
								$(this).remove();
							});
						}
						
						//读取城市列表
						var info = {
							page: 1,
							rows: 100,
							groupsId: addr.provid,
							type:"select"
						};
						
						//接口调用
						doPost("base/getCityList",info,function(data){
							//加载数据列表
							if(data.success){
								var data = data.data;
								var r = data.rows;
								var str = '';
								for(var i = 0; i < r.length; i++) {
									syslog(r[i]);
									str += '<option value=' + r[i].id + '>' + r[i].cityname + '</option>';
								}
								$('#city').html(str);
								document.getElementById('city').value = addr.cityid;
							}
						});
						//读取区域
						var info = {
							page: 1,
							rows: 1000,
							cityname: addr.city,
							type: "select"
						};
						doPost("base/getAreaList",info,function(data){
							
							if(data.success){
								var data = data.data;
								var r = data.rows;
								var str = '';
								//syslog(r);
								for(var i = 0; i < r.length; i++) {
									syslog(r[i]);
									str += '<option value=' + r[i].id + '>' + r[i].area + '</option>';
								}
								$('#area').html(str);
								document.getElementById('area').value = addr.areaid;
							}
						});
					var examines= r[0].examine;
					var strs=getExamines(examines);
					$('#examines').html(strs);
					}
				
				});
	
			}
		});
		if(re['action'] == 'edit' ){
			$('#reviewOK').css('display','none');
			$('#refuse').css('display','none');
		}
		if(re['action'] == 'review'){
			$('#submitinfo').css('display','none');
		}
		$('input[name="status"]').attr('disabled','disabled');
		if(sets.isShopUser){
			$('#reviewOK').css('display','none');
			$('#refuse').css('display','none');
			$('#submitinfo').css('display','none');
			$('#add_edit_close_btn').css('display','none');
		}
	}
	if(re['action'] == 'create'){
		//新增场馆场景
		$('#reviewOK').css('display','none');
		$('#refuse').css('display','none');
		//读取省列表
		var info = {
			page: 1,
			rows: 100,
			type:"select"
		};
		
		//接口调用
		var str = '';
		doPost("base/getGroupsList",info,function(data){
			//加载数据列表
			if(data.success){
				var data = data.data;
				var r = data.rows;
				for(var i = 0; i < r.length; i++) {
					syslog(r[i]);
					str += '<option value=' + r[i].id + '>' + r[i].name + '</option>';
				}
				$('#prov').html(str);
			}
		});
		$('input[name="status"][value="1"]').attr("checked",true);
		$('input[name="status"]').attr('disabled','disabled');
		$('input[name="rate"][value="4"]').attr("checked",true);
	}

	if(re['action'] == 'review'){
		//审核场馆场景
		//读取省列表
		var info = {
			page: 1,
			rows: 100,
			type:"select"
		};
		
		//接口调用
		var str = '';
		doPost("base/getGroupsList",info,function(data){
			//加载数据列表
			if(data.success){
				var data = data.data;
				var r = data.rows;
				for(var i = 0; i < r.length; i++) {
					syslog(r[i]);
					str += '<option value=' + r[i].id + '>' + r[i].name + '</option>';
				}
				$('#prov').html(str);
			}
		});
		$('input[name="status"][value="1"]').attr("checked",true);
		$('input[name="status"]').attr('disabled','disabled');
			
	}


    $(document).on('click' , '#load_map_modal_btn' , function(e){
        e.preventDefault();
        $('#map_modal').modal('show');
    });
 
    //弹出地图框
    $('#map_modal').on('shown.bs.modal', function (e) {
		var address = $('[name="address"]').val();
		if(address.length == 0 || address == null){
			alert('请填写场馆地址');
		}else{
            var map = new BMap.Map("allmap");
            //var point = new BMap.Point(114.340321,30.552046);
            var opts = {type: BMAP_NAVIGATION_CONTROL_LARGE};
            map.addControl(new BMap.NavigationControl(opts));  

			// 创建地址解析器实例
			var myGeo = new BMap.Geocoder();
			
			// 将地址解析结果显示在地图上,并调整地图视野
			myGeo.getPoint(address, function(point){
				if (point) {
					map.centerAndZoom(point, 16);
					map.addOverlay(new BMap.Marker(point));
				}else{
					alert("您输入的地址没有解析到结果!");
				}
			}, "武汉市");
			
			map.addEventListener("click", function(e){
                //alert(e.point.lng + ", " + e.point.lat);
                map.clearOverlays();
                var point = new BMap.Point(e.point.lng,e.point.lat);
                var marker = new BMap.Marker(point);  // 创建标注
                var geoc = new BMap.Geocoder();
                map.addOverlay(marker);               // 将标注添加到地图中
                map.enableScrollWheelZoom(true);  //开启鼠标滚轮缩放
                marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                
                $('input[name="lng"]').val(e.point.lng);
                $('input[name="lat"]').val(e.point.lat);
                
                var pt = e.point;
//              geoc.getLocation(pt, function(rs){
//                var addObj = $('[name="address"]').val(rs.address) ;
//              }); 
            });
        }
        
    });
	
	$('#add_edit_close_btn').click(function(){
		window.history.go(-1);
	});		
	
	//提交表单
	$('#submitinfo').click(function(){
		
		//获取页面参数
		var r = GetRequest();
		//编辑场景，修改场馆信息
		if(re['action'] == 'edit' ){
			var info = {
				type: "update",
				id: parseInt($('[name="id"]').val()),
				name: $('[name="name"]').val(),
				code: $('input[name="code"]').val(),
				WebContent: $('[name="address"]').val(),
				status: 1,// 待审核  parseInt($('input[name="status"]:checked').val()),
				signs: parseInt($('input[name="isSign"]:checked').val()),
				rate: parseInt($('input[name="rate"]:checked').val()),
				isview: parseInt($('input[name="isView"]:checked').val()),
				isrecommend: parseInt($('input[name="isRecommend"]:checked').val()),
				detail:$('[name="detail"]').val(),
				phone:$('[name="phone"]').val(),
				attachmentId: parseInt($('#shop-icon').attr('data-id')),
				cityId: parseInt(document.getElementById('city').value),
				groupId: parseInt(document.getElementById('prov').value),
				areaId: parseInt(document.getElementById('area').value),
				lng: $('[name="lat"]').val(),
				lat: $('[name="lng"]').val(),
				params:[]
			};
			$('.shop_img_list').each(function(i){
				info.params.push({shopImgAttachmentId: parseInt($(this).attr('data-id'))});
			});
			var str = '';
			doPost("shop/addByShop",info,function(data){
				
				if(data.success){
					//关闭页面
					alert("修改成功");
					window.history.go(-1);
				}else if(data.code == 400){
			alert(data.desc);
		            }
			});
		}
		//新建场景，插入管理用户
		if(re['action'] == 'create'){
			var info = {
				type: "add",
				id: parseInt($('[name="id"]').val()),
				name: $('input[name="name"]').val(),
				code: $('input[name="code"]').val(),
				address: $('[name="address"]').val(),
				status: 1, //待审核
				signs: parseInt($('input[name="isSign"]:checked').val()),
				rate: parseInt($('input[name="rate"]:checked').val()),
				isview: parseInt($('input[name="isView"]:checked').val()),
				isrecommend: parseInt($('input[name="isRecommend"]:checked').val()),
				detail:$('[name="detail"]').val(),
				phone:$('[name="phone"]').val(),
				attachmentId: parseInt($('#shop-icon').attr('data-id')),
				cityId: parseInt(document.getElementById('city').value),
				groupId: parseInt(document.getElementById('prov').value),
				areaId: parseInt(document.getElementById('area').value),
				lng: $('[name="lat"]').val(),
				lat: $('[name="lng"]').val(),
				params:[]
			};
			
			$('.shop_img_list').each(function(i){
				info.params.push({shopImgAttachmentId: parseInt($(this).attr('data-id'))});
			});
			
			var str = '';
			doPost("shop/addByShop",info,function(data){
				
				if(data.success){
					//关闭页面
					alert("创建成功");
					window.history.go(-1);
				}else if(data.code == 400){
			           alert(data.desc);
		            }
			});
		}
	});
	
	$('#prov').change(function(){
		//读取城市列表
		var info = {
			page: 1,
			rows: 100,
			groupsId: parseInt(document.getElementById('prov').value),
			type:"select"
		};
		
		//接口调用
		doPost("base/getCityList",info,function(data){
			//加载数据列表
			if(data.success){
				var data = data.data;
				var r = data.rows;
				var str = '';
				for(var i = 0; i < r.length; i++) {
					syslog(r[i]);
					str += '<option value=' + r[i].id + '>' + r[i].cityname + '</option>';
				}
				$('#city').html(str);
				//读取区域
				var info = {
					page: 1,
					rows: 1000,
					cityname: document.getElementById('city').options[document.getElementById('city').selectedIndex].text,
					type: "select"
				};
				doPost("base/getAreaList",info,function(data){
					
					if(data.success){
						var data = data.data;
						var r = data.rows;
						var str = '';
						//syslog(r);
						for(var i = 0; i < r.length; i++) {
							syslog(r[i]);
							str += '<option value=' + r[i].id + '>' + r[i].area + '</option>';
						}
						$('#area').html(str);
					}
				});
			}
		});
	});
	
	$('#city').change(function(){
		//读取区域
		var info = {
			page: 1,
			rows: 1000,
			cityname: document.getElementById('city').options[document.getElementById('city').selectedIndex].text,
			type: "select"
		};
		doPost("base/getAreaList",info,function(data){
			
			if(data.success){
				var data = data.data;
				var r = data.rows;
				var str = '';
				//syslog(r);
				for(var i = 0; i < r.length; i++) {
					syslog(r[i]);
					str += '<option value=' + r[i].id + '>' + r[i].area + '</option>';
				}
				$('#area').html(str);
			}
		});
	});
	
});

//审核通过
$('#reviewOK').click(function(){
	var info = {
		type: "update",
		id: parseInt($('[name="id"]').val()),
		status: 2,
	};
	var str = '';
	doPost("shop/addByShop",info,function(data){
		
		if(data.success){
			//关闭页面
			alert("审核成功");
			window.history.go(-1);
		}else if(data.code == 400){
			  alert(data.desc);
		 }
	});
});

//新增时段
$('#refuse').click(function(e){
    e.preventDefault();
    $('#shop_modal').modal('show'); 
	
});
//新增时段-保存
$('#item_submit_save').click(function(e){
	//新增提交数据
	var info = {
		examineid: parseInt($('#shopid').val()),
		type: "shop",
		content: $('#examineContent').val()	
	};
	doPost("system/review",info,function(data){
			
		if(data.success){
			alert('提交成功');
			window.history.go(-1);
		}else if(data.code == 400){
			alert(data.desc);
		}
	});
});	


//取消
$('#item_close').click(function(e){
	$('#shop_modal').modal('hide'); 
});	
    

$('#toggle').click(function(e){
	//$(this).text($("#examines").is(":hidden") ? "审核历史收起" : "审核历史展开");
    //$("#examines").slideToggle(); 
    
     if($('#examines').is(':hidden'))
         {
         $('#examines').slideDown('slow');  
         $(this).text('审核记录收起');
       }else{
          $('#examines').slideUp('slow');
         $(this).text('展开');  
       
       }
});	
 


getExamines = function(date) {
	var str = '';
		for(var i = 0; i < date.length; i++) {
				syslog(date[i]);
				str += '<div  class="row">'+
				           '<div class="col-md-3">'+
							'<div class="form-group">'+
								'<label class="col-sm-3 control-label">审核人  :</label>'+
								'<div class="col-sm-3">'+
									'<label class="radio-inline">'+
										'<p name="examineUser">'+date[i].userName+'</p>'+
									'</label>'+
								'</div>'+
							'</div>'+
						'</div>'+
					 '<div class="col-md-3">'+
							'<div class="form-group">'+
								'<label class="col-sm-4 control-label">审核时间  :</label>'+
								'<div class="col-sm-6">'+
									'<label class="radio-inline">'+
										'<p name="examineUser">'+date[i].createtime+'</p>'+
									'</label>'+
								'</div>'+
							'</div>'+
					'</div>'+
						 '<div class="col-md-6">'+
							'<div class="form-group">'+
								'<label class="col-sm-3 control-label">审核内容  :</label>'+
								'<div class="col-sm-9">'+
									'<label class="radio-inline">'+
										'<p name="examineUser">'+date[i].content+'</p>'+
									'</label>'+
								'</div>'+
							'</div>'+
						'</div>'+
							'</div>';
						
				}
		     return  str;
}

//上传图片
var sendPhotoEx = function(){
    var photo = $('#photo').cropper('getCroppedCanvas',{ width: 400, height: 250, fillColor: '#fff' }).toDataURL('image/png');
	//准备参数
	var info = {
		file:photo
	};
	
	//接口调用
	doPost("base/upload",info,function(data){
		//加载数据列表
		if(data.success){
			var data = data.data;
            // 将上传的图片的地址填入
            var imglist = document.getElementById('shop_pics');
            
            //var str = '<div class="shop_img_list_card" data-id="' + data.id +'"><img src="' + imgurl + data.attachmentpath +'" class="shop_img_list" data-id="' + data.id +'"  data-toggle="popover" title="点击即可删除"/></div>';
            var str = '<img id="img_' + data.id +'" src="' + imgurl + data.attachmentpath +'" class="shop_img_list" data-id="' + data.id +'"  data-toggle="popover" title="点击即可删除"/>';
            imglist.innerHTML += str;
            $("#img_" + data.id).click(function(){
				$(this).remove();
			});
            
            $('#changeModal').modal('hide');
		}
		else {
                alert(data.desc);
        }
    });
}

//上传图标
var sendIconEx = function(){
    var photo = $('#icon').cropper('getCroppedCanvas',{ width: 100, height: 100, fillColor: '#fff' }).toDataURL('image/png');
	//准备参数
	var info = {
		file:photo
	};
	
	//接口调用
	doPost("base/upload",info,function(data){
		//加载数据列表
		if(data.success){
			var data = data.data;
            // 将上传的图片的地址填入
            var img = $('#shop-icon'); 
            img.attr('src', imgurl + data.attachmentpath);
            img.attr('data-id',data.id);
            $('#iconchangeModal').modal('hide');
		}
		else {
            alert(data.desc);
        }
    });
}

//选择图标
$('#select_icon').click(function(e){
	e.preventDefault();
	$('#iconchangeModal').modal('show');
});

//选择图片
$('#select_photo').click(function(e){
	e.preventDefault();
	//场馆限制为只能上传5张图
	if($('.shop_img_list').length >= 5){
		return;
	}
	$('#changeModal').modal('show');
});

$('[name="code"]').change(function(){
	$('[name="manager"]').val('mgr_' + $(this).val() + ',cw' +  + $(this).val());
});

$('.shop_img_list_card').click(function(){
	$(this).remove();
});


</script>
</body>
</html>

